package com.orange.common.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:ResultCodeEnum
 * Package:com.ywf.myproject.common.result
 * Description:
 *
 * @Date:2021/2/28 11:01
 * @Author:YWF
 */
public enum ResultCodeEnum {

    SUCCESS("00000", "成功"),
    UNKNOWN_ERROR("-20000", "未知错误"),
    PARAM_ERROR("-20001", "参数校验错误"),
    NULL_POINT("-20002", "空指针异常"),
    HTTP_CLIENT_ERROR("-20003", "Http状态码错误"),
    HTTP_UNKNOW_HOST("-20004", "未知主机"),
    METHOD_NOT_SUPPORT("-20005", "请求方法不支持"),
    REQUEST_BODY_DATA_ERROR("-20006", "请求body数据缺失或错误"),
    ERROR_CODE_BIZ("-20007", "工具类业务调用异常"),
    ERROR_BAD_SQL("-20007", "数据库SQl执行异常"),

    LIMIT_ERROR("10001", "访问过于频繁，请稍后再试"),
    SING_MISS_PARAM_ERROR("10003", "缺少必要的签名参数"),
    APPKEY_NOT_EMPTY("-20009", "APPKEY缺失，请申请获取"),
    APPKEY_IS_INVALID("-20010", "开发者账号无效"),
    REQUEST_BODY_ERROR("10006", "请求体错误"),
    NO_REPEAT_REQUEST("-20017", "请不要重复提交"),

    TOKEN_UN_VAILABLE("-20007", "TOKEN校验失败"),
    USER_NOT_LOGIN("-20008", "用户未登录或Token已过期"),
    APPKEY_NOT_COMPLETE("-20009", "APPKEY缺失，请授权"),
    PARAM_NOT_COMPLETE("-20010", "请求头参数缺失"),
    APP_VERSION_IS_INVALID("-20010", "版本号信息无效"),
    REQUEST_SOURCE_INVALID("-20011", "请求来源无效,请检查开发者账号"),
    PARAM_IS_BLANK("-20012", "参数为空"),
    PARAM_TYPE_BIND_ERROR("-20013", "参数类型错误"),
    REQUEST_TIME_INVALID("-20014", "请求时间无效"),
    REQUEST_TIME_OUT("-20015", "请求过期，请重新请求"),
    TOKEN_ERROR("-20015", "token无效"),
    SIGN_ERROR("-20016", "签名信息错误"),
    REDIS_SERVICES_NOT_START("-20017", "Redis为获取到连接池"),
    TOKEN_PARAM_IS_EMPTY("-20018", "无token，请重新登录"),

    /*用户错误*/
    USER_NOT_EXISTS("-20009", "用户未注册"),
    PWD_ERROR("-20020", "用户名或密码错误"),
    SYNC_REQUEST_TIMEOUT("-20021", "长轮询异步请求超时"),

    RESULT_NULL("-20021", "查询结果数据为空"),
    GET_NEWS_ERROR("-20022", "获取远程新闻数据出现异常"),
    CLIENT_NOT_EXISTS("-20023", "客户端不存在或未注册"),
    AGENT_HTTP_ERROR("-20024", "三方API客户端请求错误"),
    AGENT_URL_ERROR("-20025", "三方API客户端请求URL错误，请检查!"),
    SAVE_ONE_SAY_ERROR("-20026", "保存一言数据错误"),
    ;



    private Boolean success;

    private String code;

    private String msg;

    ResultCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    //校验重复的code值
    public static void main(String[] args) {
        ResultCodeEnum[] ApiResultCodes = ResultCodeEnum.values();
        List<String> codeList = new ArrayList();
        for (ResultCodeEnum ApiResultCode : ApiResultCodes) {
            if (codeList.contains(ApiResultCode.code)) {
                System.out.println(ApiResultCode.code);
            } else {
                codeList.add(ApiResultCode.getCode());
            }
        }
    }

}
